<template>
  <div class="person">
    <personCollection
    v-if="isGetCollection" 
       :allDate="collections"
       :pageSize="pageSize"
       :total="total"></personCollection>
      
  </div>
</template>

<script>
import personCollection from '@/components/personCollection.vue'
import {mapState} from "vuex";
import Footer from "@/components/footer.vue";
import {searchCollection} from '@/api/all';
export default {
  components:{
    personCollection,
    Footer
  },
  data(){
    return {
      isGetCollection:false,
      collections:[], //返回的收藏文物数据
      total:0,//总条数
      pageSize:12,//每页多少条
    }
  },
  computed:{
       ...mapState('login',["username","password","uid"]),
  },
  mounted(){
    this.init()
},
  methods:{
   async init(){
      let params={
        id:this.uid,
        username:this.username,
        password:this.password
      };
      await searchCollection(params).then(res=>{
        if(res.data.code===200){
          this.collections=res.data.data.collections;
          this.total=res.data.data.total;
          this.isGetCollection=true
        }
      }).catch(error=>{
        console.log(error)
      })
    }
  }
}
</script>

<style scoped>
.person{
  height: auto;
  background: #5f806f;
}

</style>